package com.spring.sd.cycle;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;


@Aspect
@Component
public class MyAspectj {

	@Pointcut("execution(* com.spring.sd.cycle..*B.*(..))")
	public void pointcutWeb() {
	}

	@Pointcut("execution(* com.spring.sd.cycle..*A.*(..))")
	public void pointcutWeb1() {
	}

	@Before("pointcutWeb()")
	public void doBefore(JoinPoint joinPoint) throws Throwable {
		System.out.println(">>>>>>>>>>>>>> Before aop");
	}

	@Around("pointcutWeb()")
	public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
		System.out.println("-----aop----- start");
		Object proceed = joinPoint.proceed();
		System.out.println("=====aop==== end");
		return proceed;
	}



	@Before("pointcutWeb1()")
	public void doBefore1(JoinPoint joinPoint) throws Throwable {
		System.out.println(">>>>>>>>>>>>>> Before aop1");
	}

	@Around("pointcutWeb1()")
	public Object around1(ProceedingJoinPoint joinPoint) throws Throwable {
		System.out.println("-----aop----- start1");
		Object proceed = joinPoint.proceed();
		System.out.println("=====aop==== end1");
		return proceed;
	}
}
